/**
 *  Copyright (C) 2011  Thomas ROBIN
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package menuitem;

import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import triseries.Main;
import triseries.UnwatchEpisode;

/**
 * @author tshepo
 * 
 */
public class BetaseriesLink  extends JMenuPlugins {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9034287625974402324L;
	private static boolean episodeItem = true;
	private static boolean display = false;

	/**
	 * 
	 */
	public BetaseriesLink(final UnwatchEpisode uwe) {
		super("Voir sur BetaSeries");
		
		display = true;

		this.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				URI uri = null;
				String webLink = "http://www.betaseries.com/episode/"
						+ uwe.GetUrl() + "/s" + uwe.GetSeason() + "e"
						+ uwe.GetEpisode();
				try {
					uri = new URI(webLink);
				} catch (URISyntaxException e1) {
					Main.processExeption("MyMenuItem.MyMenuItem : \n"
							+ e1.getStackTrace().toString());
				}
				try {
					Desktop.getDesktop().browse(uri);
				} catch (IOException e1) {
					Main.processExeption("MyMenuItem.MyMenuItem : \n"
							+ e1.getStackTrace().toString());
				}
			}
		});
	}
	

	/**
	 * @return the display
	 */
	public boolean isDisplay() {
		return display;
	}
	
	/**
	 * @return the episodeItem
	 */
	public boolean isEpisodeItem() {
		return episodeItem;
	}	
}
